package com.yzpass.api.user.dto;

import com.yzpass.api.user.entity.Role;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;

@Getter
@Setter
public class RoleDTO {
    private String roleId;

    private String roleName;

    private String note;

    private Boolean disable;

    private String createBy;

    private LocalDateTime createTime;

    private String updateBy;

    private LocalDateTime updateTime;

    private Boolean isSys;

    private List<ResDTO> resArr;
    public static RoleDTO fromRole(Role role){
        RoleDTO dto = new RoleDTO();
        dto.setRoleId(role.getRoleId().toString());
        dto.setRoleName(role.getRoleName());
        dto.setNote(role.getNote());
        dto.setDisable(role.getDisable());
        dto.setCreateBy(role.getCreateBy());
        dto.setCreateTime(role.getCreateTime());
        dto.setUpdateBy(role.getUpdateBy());
        dto.setUpdateTime(role.getUpdateTime());
        dto.setIsSys(role.getIsSys());
        return dto;
    }
    public Role toRole(){
        Role role = new Role();
        role.setRoleId(UUID.fromString(this.getRoleId()));
        role.setRoleName(this.getRoleName());
        role.setNote(this.getNote());
        role.setDisable(this.getDisable());
        role.setCreateBy(this.getCreateBy());
        role.setCreateTime(this.getCreateTime());
        role.setUpdateBy(this.getUpdateBy());
        role.setUpdateTime(this.getUpdateTime());
        role.setIsSys(this.getIsSys());
        return role;
    }
}
